﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using NightskyMimic.Core;
using NightskyMimic.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test.Core
{
    [TestClass]
    public class StateTest
    {
        //calculate utility of a state when opponents life is <= 0
        [TestMethod]
        public void CalculateUtilityWhenOpponentLifeIsEqualsToZero()
        {
            State state = new State(10, new List<Creature>(), -1, new List<Creature>(), new List<Block>(), new List<Attack>(), null);

            Assert.AreEqual(Double.PositiveInfinity, state.Utility);
        }

        //calculate utility of a stat when my life is <= 0
        [TestMethod]
        public void CalculateUtilityWhenMyLifeIsEqualsToZero()
        {
            State state = new State(-1, new List<Creature>(), 10, new List<Creature>(), new List<Block>(), new List<Attack>(), null);

            Assert.AreEqual(Double.NegativeInfinity, state.Utility);
        }

        //calculate utility of a stat when my life and opponents life are 20
        // I have 2 creatures 1/1
        //Opponent have 1 creature 1/1 and one 2/2
        [TestMethod]
        public void CalculateUtilityWhithManyCreatures()
        {
            List<Creature> myCreatures = new List<Creature>() { new Creature("c1", 0, 1, 1), new Creature("c2", 0, 1, 1) };
            List<Creature> opponentCreatures = new List<Creature>() { new Creature("c3", 0, 1, 1), new Creature("c4", 0, 2, 2) };
            State state = new State(20, myCreatures, 20, opponentCreatures, new List<Block>(), new List<Attack>(), null);

            Assert.AreEqual(-0.04166666666666663, state.Utility);
        }

        //calculate utility of a state when there is no creatures
        [TestMethod]
        public void CalculateUtilityWhithNoCreatures()
        {
            State state = new State(20, new List<Creature>(), 20, new List<Creature>(), new List<Block>(), new List<Attack>(), null);

            Assert.AreEqual(0, state.Utility);
        }
    }
}
